package edu.washington.cs.workflow.analysis.guistructure.uievents;

import edu.washington.cs.workflow.util.Utils;

public class UIEventThreadExecutor {
	
	public static long timelimit = 10000l;

	public static UIEventOutcome executeUIEvent(UIEvent e) {
		return executeUIEvent(e, timelimit);
	}
	
	public static UIEventOutcome executeUIEvent(UIEvent e, long timelimit) {
		Utils.checkTrue(timelimit > 0);
		UIEventThread t = new UIEventThread();
		t.setUIEvent(e);
		try {
			t.start();
			t.join(timelimit);
			t.stop();
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}
		return t.getOutcome();
	}
}